Skip to content

Migrate to pysepal 4.0 - #24

Merged
dfguerrerom merged 11 commits into
mainfrom
feat/pysepal-v4
Aug 20, 2026
Merged

Migrate to pysepal 4.0#24
dfguerrerom merged 11 commits into
mainfrom
feat/pysepal-v4

Conversation

@dfguerrerom

@dfguerrerom dfguerrerom commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Moves the app onto pysepal 4.0 and folds in the tile band-aid cleanup that was
split across #20, #22 and #23, which this replaces.

v4 deletes the sepal_ui package, so every import is renamed; theme moves from
per-widget ThemeToggle to a scope-keyed ThemeState, threaded through the
charts; and the local comm-bridge component is gone, because localtileserver 1.0
stands up jupyter-loopback itself and LOCALTILESERVER_CLIENT_PREFIX decides the
transport. SEPAL sets that prefix, so app.py copies it to
VECTORTILESERVER_CLIENT_PREFIX too -- vectortileserver never autodetects one,
and without it the PMTiles points silently never load.

Two bugs surfaced while testing on a sandbox and are fixed here. The class
palette and the tiled COG are produced by independent async paths, and when the
COG won the race the raster was drawn with an empty palette -- every class down
the dark end of the default ramp, permanently, since the status latched. And a
vector upload crashed the map effect with RasterioIOError; only rasters are
supported, so they are now rejected at selection.

Tested locally and on a SEPAL sandbox under both Voila and Jupyter: class raster,
PMTiles points, dark theme and the full analysis all render. 201 tests pass.

pysepal is unblocked: 4.0.0rc0 is on PyPI, and the pin now reads
pysepal>=4.0.0rc0. The floor names the pre-release deliberately, since pip only
considers one when the specifier itself mentions one -- plain >=4.0.0 matched
nothing at all and the environment failed to resolve. Every symbol this branch
imports resolves against the rc, add_raster takes class_colors, and the wheel
ships no sepal_ui.

Still blocked on vectortileserver 0.2.2. The loopback bind and the tippecanoe
lookup are merged upstream, but the version string is still 0.2.1 and nothing
above 0.2.1 is on PyPI, so vectortileserver>=0.2.2 keeps CI from resolving the
environment until that release goes out.

vectortileserver 0.2.2 binds 127.0.0.1 and resolves tippecanoe next to the
interpreter itself, so the app no longer patches around either.

Removing the PATH mutation exposed that the GDAL CLI lookup had the same
problem, and was only ever fixed by that side effect -- and only when points
happened to be rendered first, so a second raster upload took a different code
path than the first. Resolve the GDAL tools the same way instead.
Categorical rendering was never app-specific: the discrete LUT, the
server-side registration that keeps per-class alpha, and the COG preparation
now live in SepalMap.add_raster behind class_colors. SbaeMap just inherits it,
so the local add_class_raster, _optimize_for_tiles, _build_class_colormap and
scripts/tiling.py all go, and the inert LOCALTILESERVER_HOST knob goes with
the TileClient call that carried it.

classification_layer was assigned twice and read nowhere; dropped.

Needs pysepal 3.9.0.
Renames the sepal_ui imports, moves theme onto ThemeState, and drops the
local comm-bridge component: localtileserver 1.0 stands up jupyter-loopback
itself, so the transport is decided by LOCALTILESERVER_CLIENT_PREFIX. Copy
that route to vectortileserver, which never autodetects one, or the PMTiles
points silently never load on SEPAL.
The tiled COG and the class palette are produced by two independent async
paths. When the COG won the race the raster was added with an empty palette,
so every class rendered down the dark end of the default continuous ramp --
silently, and permanently, since the status latched to "finished" and the
layer was never redrawn. Gate the add on the palette instead, and clear it
with the rest of the file state so the next raster cannot inherit it.
A vector upload computed areas fine, then tried to show the file with
add_raster, which opens with rasterio and raised RasterioIOError out of a
use_effect. Only rasters are supported, so reject them at selection and drop
the branch that drew them.
@dfguerrerom
dfguerrerom merged commit c805614 into main Aug 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant